[id].vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 导航栏 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 列表页广告一 -->
  7. <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
  8. <!-- 资讯列表 -->
  9. <div class="newsDetail">
  10. <div class="inner">
  11. <div class="innerLeft">
  12. <!-- 面包屑导航 -->
  13. <div class="breadcrumb breadcrumb_phone_none">
  14. <div class="inner">
  15. <span class="location">当前位置:</span>
  16. <el-breadcrumb :separator-icon="ArrowRight">
  17. <el-breadcrumb-item>
  18. <NuxtLink to="/">首页</NuxtLink>
  19. </el-breadcrumb-item>
  20. <el-breadcrumb-item v-if="parent_name != ''">
  21. <NuxtLink :to="`/${parent_pinyin}/list-1.html`"> {{ parent_name }}</NuxtLink>
  22. </el-breadcrumb-item>
  23. <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
  24. </el-breadcrumb>
  25. </div>
  26. </div>
  27. <div class="breadcrumb_box breadcrumb_pc_none">
  28. <span class=" ">当前位置:</span>
  29. <NuxtLink to="/">首页</NuxtLink>
  30. <span class=" " v-if="parent_name != ''">&gt;</span>
  31. <NuxtLink v-if="parent_name != ''" :to="`/${parent_pinyin}/list-1.html`"> {{ parent_name }}</NuxtLink>
  32. <span class=" " >&gt;</span>
  33. <span class=" " >{{ routeNewsTtitle }}</span>
  34. </div>
  35. <div class="LeftTop">
  36. <h1>{{ newsDetail.title }}</h1>
  37. <p class="phone_none">
  38. 来源: <span>{{ newsDetail.copyfrom }}</span>
  39. 作者: <span>{{ newsDetail.author }}</span>
  40. 发布时间: <span>{{ time }}</span>
  41. </p>
  42. <p class="pc_none">
  43. <span>{{ newsDetail.copyfrom }}</span>
  44. <span>{{ newsDetail.author }}</span>
  45. <span>{{ time }}</span>
  46. </p>
  47. </div>
  48. <div class="leftBottom" v-html="newsDetail.content" v-if="newsDetail.content" @click="openPreview">
  49. </div>
  50. <div v-if="previewVisible" class="preview-modal" @click="closePreview">
  51. <img :src="selectedImage" alt="Preview">
  52. </div>
  53. <!-- 免责声明: -->
  54. <div class="disclaimer" v-if="newsDetail.copyfrom != '本网'">
  55. <p>原文链接:{{ newsDetail.fromurl }}</p>
  56. <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
  57. </div>
  58. <div v-if="articleChoice">
  59. <HomeSurveyvote></HomeSurveyvote>
  60. </div>
  61. <!-- 推荐阅读 -->
  62. <div class="recommendRead" v-if="newsDetail.commendArticle != false">
  63. <div class="recommendReadTitle phone_none">
  64. 推荐阅读
  65. </div>
  66. <div class="phone_box_1_head pc_none">
  67. <a class="" title="">推荐阅读</a>
  68. </div>
  69. <div class="recommendReadList">
  70. <div class="recommendReadListTitle" v-for="(item, index) in newsDetail.commendArticle"
  71. :key="item.id">
  72. <a :href="`/${item.alias_pinyin}/${item.id}.html`" v-if="index < 3">
  73. {{ item.title }}
  74. </a>
  75. <span v-if="index < 3">{{ getTime(item.created_at, "month", 1) }}</span>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. <div class="innerRight">
  81. <!-- 热点资讯1 -->
  82. <div class="hotList1">
  83. <DetailHotNews></DetailHotNews>
  84. </div>
  85. <!-- 热点资讯2 -->
  86. <div class="hotList2">
  87. <DetailHotNews2></DetailHotNews2>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. <!-- 列表页广告一 -->
  93. <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
  94. <!-- 页面底部 -->
  95. <HomeFoot1></HomeFoot1>
  96. </template>
  97. <script setup>
  98. //1.页面依赖 start ---------------------------------------->
  99. import { onMounted } from 'vue'
  100. import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
  101. import { ArrowRight } from '@element-plus/icons-vue'
  102. //1.页面依赖 end ---------------------------------------->
  103. //2.页面路径 start ---------------------------------------->
  104. const targetSegment = getRoutePath(1);
  105. let routeId;
  106. //通过导航路径反向查询导航id
  107. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  108. method: 'GET',
  109. query: {
  110. 'pinyin': targetSegment,
  111. },
  112. });
  113. if (getRouteId.code == 200) {
  114. routeId = getRouteId.data.category_id
  115. } else {
  116. console.log("错误位置:获得页面路径")
  117. }
  118. //2.页面路径 start ---------------------------------------->
  119. //3.面包屑 start ---------------------------------------->
  120. const route = useRoute();
  121. const articleId = parseInt(route.params.id); //获得该页面的id
  122. //3.1 获得父级栏目的名称、id
  123. const parent_name = ref([]);
  124. const parent_id = ref([]);
  125. const parent_pinyin = ref("");
  126. const parent_children_count = ref(0)
  127. let getParentNav = async () => {
  128. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  129. method: 'GET',
  130. query: {
  131. 'catid': routeId
  132. },
  133. });
  134. if (listData.code == 200) {
  135. parent_name.value = listData.data.alias;
  136. parent_id.value = listData.data.parent_id;
  137. parent_pinyin.value = listData.data.aLIas_pinyin;
  138. parent_children_count.value = listData.data.children_count;
  139. } else {
  140. console.log("错误位置:获取面包屑导航")
  141. }
  142. }
  143. getParentNav();
  144. //3.页面依赖 end ---------------------------------------->
  145. //4.页面数据 start ---------------------------------------->
  146. //4.1 资讯详情
  147. const newsDetail = ref({})
  148. const routeNewsTtitle = ref("");
  149. //4.2 发布日期
  150. const time = ref("");
  151. //4.3 路径
  152. const routLevelTitle = ref("");
  153. const routLevelId = ref("");
  154. //4.4 是否展示投票
  155. const articleChoice = ref(false);
  156. //4.5 获取详情
  157. async function getPageData() {
  158. const mkdata = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  159. method: 'GET',
  160. query: {
  161. 'articleid': articleId
  162. },
  163. });
  164. if (mkdata.code == 200) {
  165. //判断是否显示投票
  166. if (mkdata.data.is_survey == 1) {
  167. console.log("本篇文章含有投票!")
  168. articleChoice.value = true;
  169. }
  170. //获取内容
  171. newsDetail.value = mkdata.data;
  172. //获取路径
  173. routLevelTitle.value = newsDetail.value.cat_name;
  174. routLevelId.value = newsDetail.value.category_id;
  175. //获取发布时间
  176. time.value = newsDetail.value.updated_at.split(' ')[0];
  177. //修正标题长度
  178. if (newsDetail.value.title.length >= 20) {
  179. routeNewsTtitle.value = newsDetail.value.title.substr(0, 20) + "...";
  180. } else {
  181. routeNewsTtitle.value = newsDetail.value.title
  182. }
  183. } else {
  184. console.log("错误位置:获取详情内容")
  185. }
  186. }
  187. getPageData();
  188. //4.页面数据 end ---------------------------------------->
  189. //5.广告 start ---------------------------------------->
  190. let adImg1 = ref([]);
  191. let adImg2 = ref([]);
  192. onMounted(async () => {
  193. const { $webUrl, $CwebUrl } = useNuxtApp();
  194. //广告1
  195. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nmgw_detail_0001`
  196. const responseAd1 = await fetch(url, {
  197. headers: {
  198. 'Content-Type': 'application/json',
  199. 'Userurl': $CwebUrl,
  200. 'Origin': $CwebUrl
  201. }
  202. });
  203. const resultAd1 = await responseAd1.json();
  204. adImg1.value = resultAd1.data[0];
  205. //广告2
  206. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nmgw_detail_0002`
  207. const responseAd2 = await fetch(url2, {
  208. headers: {
  209. 'Content-Type': 'application/json',
  210. 'Userurl': $CwebUrl,
  211. 'Origin': $CwebUrl
  212. }
  213. });
  214. const resultAd2 = await responseAd2.json();
  215. adImg2.value = resultAd2.data[0];
  216. })
  217. //5.广告 end ---------------------------------------->
  218. //6.设置seo信息 start---------------------------------------->
  219. const setData = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  220. method: 'GET',
  221. query: {
  222. 'articleid': articleId
  223. },
  224. });
  225. if (setData.code == 200) {
  226. let seoTitle = setData.data.title;
  227. let seoDescription = setData.data.introduce;
  228. let seoKeywords = setData.data.keyword;
  229. let seoSuffix = setData.data.suffix;
  230. let seoName = setData.data.website_name;
  231. useSeoMeta({
  232. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  233. meta: [
  234. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  235. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  236. { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',tagPriority: 10 }
  237. ]
  238. });
  239. } else {
  240. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  241. // console.log("错误位置:设置详情页面SEO数据")
  242. // console.log("后端错误反馈:", setData.message)
  243. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  244. }
  245. //6.设置seo信息 end---------------------------------------->
  246. //8.页面图片放大 start---------------------------------------->
  247. const previewVisible = ref(false)
  248. const selectedImage = ref(' ')
  249. const openPreview = (event) => {
  250. if (event.target.tagName === 'IMG') {
  251. selectedImage.value = event.target.src;
  252. previewVisible.value = true;
  253. }
  254. }
  255. const closePreview = () => {
  256. previewVisible.value = false;
  257. }
  258. //8.页面图片放大 end---------------------------------------->
  259. </script>
  260. <style lang="less" scoped>
  261. @import url('@/assets/css/detail.less');
  262. </style>
  263. <style lang="less" scoped>
  264. @media screen and (min-width:801px){/*pc*/
  265. .breadcrumb_pc_none{display:none!important;}
  266. .pc_none{display:none;}
  267. }
  268. @media screen and (max-width:800px){/*ipad_phone*/
  269. .index_3_box_vote{overflow:hidden;margin-top:39px;}
  270. .index_3_box_vote .inquire{margin-top:15px;height:auto;}
  271. .index_3_box_vote .inquire p{height:auto;padding:0;font-size:14px;
  272. margin:0px 0px 5px 18px;}
  273. .index_3_box_vote .inquire .radio .el-radio.el-radio--large .el-radio__label span{font-size:14px;}
  274. .index_3_box_vote .voteTitle{font-size:14px;}
  275. .index_3_box_vote .inquire .btn{padding-left:22px;}
  276. .index_3_box_vote .inquire .radio .el-radio.el-radio--large{margin-bottom:3px;}
  277. .index_3_box_vote .inquire .radioBox{height:auto;
  278. padding:0px 0px 12px 18px;}
  279. .index_3_box_vote .inquire .radio .el-radio-group{width:100%;}
  280. .index_3_box_vote .inquire .btn button{width:auto;padding:0px 10px;line-height:33px;height:33px;font-size:14px;margin-bottom:14px;}
  281. .newsDetail .inner{width:92%;}
  282. .newsDetail .inner .innerLeft{width:100%;margin:0;float:none; }
  283. .newsDetail .inner .innerLeft .LeftTop{margin-top:9px;border-top:solid 1px #489d97;}
  284. .newsDetail .inner .innerLeft .LeftTop > h1{font-size:20px;line-height:28px;margin:15px auto 15px;}
  285. .newsDetail .inner .innerLeft .leftBottom{width:100%; }
  286. .newsDetail .inner .innerLeft .leftBottom{margin-top:20px;font-size:16px!important;line-height:24px!important; }
  287. .newsDetail .inner .innerLeft .leftBottom *{ font-size:16px!important;line-height:24px!important; }
  288. .newsDetail .inner .innerLeft .leftBottom /deep/img{max-width:100%;height:auto; }
  289. .newsDetail .inner .innerLeft .LeftTop > p{height:auto;}
  290. .breadcrumb_box{
  291. height:22px;width:100%;margin:16px auto 9px;
  292. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  293. font-size:14px;
  294. color:#666;
  295. *{
  296. font-size:14px;
  297. display:inline ;
  298. color:#666;
  299. line-height:22px;height:22px;
  300. margin-right:5px;
  301. }
  302. }
  303. .newsDetail .inner .innerLeft .disclaimer{width:100%; }
  304. .newsDetail .inner .innerLeft .disclaimer *{word-wrap: break-word;width:100%!important;display:block!important;
  305. overflow-wrap: break-word;font-size:16px;
  306. white-space: pre-wrap;
  307. word-break: break-all;
  308. }
  309. .newsDetail .inner .innerLeft .recommendRead{width:100%;}
  310. .newsDetail .inner .innerLeft .recommendRead .recommendReadList{
  311. height:auto;margin-top:11px; min-height:auto;padding-bottom:8px;
  312. }
  313. .newsDetail .inner .innerLeft .recommendRead .recommendReadList .recommendReadListTitle{
  314. margin-top:0px;overflow:hidden;width:100%;
  315. }
  316. .newsDetail .inner .innerLeft .recommendRead .recommendReadList .recommendReadListTitle a{
  317. line-height:33px;height:33px;font-size:14px;float:left;max-width:90%;font-weight:normal;
  318. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  319. }
  320. /* // 推荐阅读 */
  321. .phone_box_1_head{
  322. height:33px;line-height:33px;
  323. background:#fff;border-bottom:1px solid #E6E6E6;
  324. margin-top:15px;width:100%;
  325. a{
  326. float:left;height:33px;line-height:33px;margin:0;position:relative;text-indent:8px;
  327. color:#489d97;font-size:14px; font-weight:bold;box-sizing:border-box;
  328. }
  329. a::before{
  330. content: '';display: block;
  331. position:absolute;left:0px;top:12px;
  332. background: linear-gradient(to top, #0998A9, #6ADDD6);
  333. width:3px;height:10px;
  334. }
  335. }
  336. .newsDetail .inner .innerLeft .LeftTop > p span:nth-last-of-type(1){margin-right:0px;}
  337. .newsDetail .inner .innerLeft .recommendRead .recommendReadList .recommendReadListTitle span{display:none;}
  338. .newsDetail .inner .innerRight{display:none;}
  339. .breadcrumb_phone_none{display:none!important;}
  340. .phone_none{display:none;}
  341. }
  342. </style>